/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.levelup.threads;

import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 * @author WORKSPOT2
 */
public class PartManager
{

    public void process()
    {
        AtomicInteger counter = new AtomicInteger(0);
        Thread tr1 = new Thread(new PartProcessor(counter,300));
        counter.incrementAndGet();
        tr1.start();
        Thread tr2 = new Thread(new PartProcessor(counter,200));
        counter.incrementAndGet();
        tr2.start();
        Thread tr3 = new Thread(new PartProcessor(counter,400));
        counter.incrementAndGet();
        tr3.start();
        try
        {
            while (counter.get() > 0)
            {
                System.out.println("Waiting! Counter is: " + counter.get());
                Thread.sleep(500);
            }
        }
        catch (Exception e)
        {
        }
    }
}
